<template>
	<view class="content">
		<userInfo :user='user' />
    <view class="top tac fw">
      <text>请完善</text>
      <text class="color">基本信息</text>
    </view>
		<view class="messageBar fz12" v-for="item,index in columns" :key="index">
			<view class="disb aic">
				<text>{{item.className}}</text>
				<view class="select disp aic">
					<text class="color9" v-if="item.category" @click="click(index,item.className)">{{item.category}}</text>
					<u--input
						v-else
					    placeholder="请输入"
						inputAlign='right'
						fontSize='12'
						border='none'
					    v-model="item.category"
					></u--input>
					<image src="../../static/images/preat/right.png" mode="" @click="click(index,item.className)"></image>
				</view>
			</view>
		</view>
		<u-picker :show="show" :immediateChange="true" :columns="questionList" keyName="category" @confirm="sexSelect" @cancel='show=false' closeOnClickOverlay  @close='show=false'></u-picker>
		<view class="upBtn tac colorf" @click="toSee">提交</view>
	</view>
</template>

<script>
	import {getPublicitySelectListByTypesName,getPublicitySelectListByClassName} from "../../api/information.js"
	import userInfo from "../../components/userInfo/userInfo.vue"
	export default {
		components:{
			userInfo
		},
		data() {
			return {
				show:false,
				select:null,
				user:uni.getStorageSync('userInfo'),
				typesName:'',
				columns:[],
				questionList:[]
			};
		},
		onLoad(option) {
			if(option.id==1){
				this.typesName = '完成全款车按揭车信贷公式表'
				uni.setNavigationBarTitle({
					title: '添加车辆资料'
				})
			}
			if(option.id==2){
				this.typesName = '完成按揭房信贷公式表'
				uni.setNavigationBarTitle({
					title: '添加按揭房资料'
				})
			}
			this.getMessage()
		},
		methods:{
			getMessage(){
				getPublicitySelectListByTypesName({typesName:this.typesName}).then(res => {
					res.data.forEach(v => {
						if(v.category=='手动输入'){
							v.category = ''
						}
					})
					this.columns = res.data
				})
			},
			//选择
			click(i,name){
				this.select = i
				this.show = true
				let parmas = {className:name}
				getPublicitySelectListByClassName(parmas).then(res => {
					this.questionList = [res.data]
				})
			},
			//确认选择
			sexSelect(e) {
				this.show = false
				this.columns[this.select].category = e.value[0].category
			},
			//额度评估
			toSee(){
				uni.navigateTo({
					url:"/pages/category/testLimit"
				})
			},
			//获取问题
			getQuestion(){
				
			},
			//性别
			getSex(i){
				if(i==1){
					return '男'
				}
				if(i==2){
					return '女'
				}
				if(i==3){
					return '未知'
				}
			}
		}
	}
</script>

<style lang="scss">
.content{
	min-height: 100vh;
	padding-bottom: 1rpx;
	background-color: #f7f7f7;
}
.top{
	line-height: 80rpx;
	background-color: #d8e6ff;
	color: blue;
}
.messageBar{
	min-height: 80rpx;
	line-height: 80rpx;
	padding: 0 30rpx;
	margin-bottom: 10rpx;
	background-color: #fff;
	.select{
		image{
			width: 20rpx;
			height: 30rpx;
			margin-left: 10rpx;
		}
	}
	.selectBar{
		padding-bottom: 20rpx;
		.selectIt{
			background-color: #0055ff;
			color: #fff;
		}
	}
	.btn{
		width: 150rpx;
		line-height: 60rpx;
		margin-right: 10rpx;
		border-radius: 30rpx;
		background-color: #ccc;
	}
}
.upBtn{
	width: 80%;
	line-height: 80rpx;
	border-radius: 40rpx;
	background-color: #0055ff;
	margin: 40rpx auto 20rpx;
}
</style>
